package ar.com.angrymachine.hunter.activities;

import ar.com.angrymachine.hunter.Game;
import ar.com.angrymachine.hunter.HunterResourceManager;
import ar.com.angrymachine.hunter.gameplay.Monster;

public class SplittingMonsterActivity extends FightActivity
{
	private Monster originalForm;
	private int splits;
	public SplittingMonsterActivity(Monster monster, int splits)
	{
		super(monster);
		this.splits = splits;
		originalForm = (Monster) monster.clone();
	}
	
	protected void die()
	{
		if(splits > 0)
		{
	    	Monster split1 = (Monster) originalForm.clone();
	    	Monster split2 = (Monster) originalForm.clone();
	    	split1.setMaxHealth(monster.getMaxHealth()/2);
	    	split2.setMaxHealth(monster.getMaxHealth()/2);
	    	if(splits == 1)
	    	{
	    		split1.icon = split2.icon = HunterResourceManager.getImage("monster-splitting-small.png");
	    	}
	    	else
	    	{
	    		split1.icon = split2.icon = HunterResourceManager.getImage("monster-splitting-mid.png");	    		
	    	}
	    	// split!
	    	Game.current.currentLevel.addActivity(this, new SplittingMonsterActivity(split1, splits - 1));
	    	Game.current.currentLevel.addActivity(this, new SplittingMonsterActivity(split2, splits - 1));
		}
		super.die();
	}
}
